<template>
  <div class="download-paper clearfix" id="downloadPaper">
    <div class="dp-box" v-for="(item, idx) in userList" :key="idx">
      <div class="dp-top">
        <div class="top-left">
          <p class="title">
            {{ item.examDate.substring(0, 4) }}年宁波市初中学业水平考试<br/>
            科学实验操作考试
          </p>
          <p class="title-card">准&nbsp;&nbsp;&nbsp;&nbsp;考&nbsp;&nbsp;&nbsp;&nbsp;证</p>
          <div class="clearfix">
            <div class="tl-block tl-info">
              <p>姓名：{{ item.name }}</p>
              <p>性别：{{ item.sex }}</p>
            </div>
            <div class="tl-block">
              <p>准考证号：{{ item.ticketCard }}</p>
              <p class="graduation-school">
                <span class="lab">毕业学校：</span>
                <span>{{ item.graduation }}</span></p>
            </div>
          </div>
        </div>
        <div class="top-right">
          <div class="img" :style="{backgroundImage: 'url('+item.img+')'}"></div>
        </div>
      </div>
      <div class="dp-bottom">
        <div class="dpb-block">
          <p>考点学校：{{ item.examinationPoint }}</p>
          <p>考试日期：{{ item.examinationDate }}</p>
          <p>候考时间：{{ item.waitintTime }}</p>
        </div>
        <div class="dpb-block">
          <p>考场编号：{{ item.bianhao }}</p>
          <p>座位号：{{ item.zwh }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;批次：{{ item.pc }}</p>
          <p>考试时间：{{ item.examinationTime }}</p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'download',
  data () {
    return {
      userList: []
    }
  },
  created () {
    for (let i = 0; i < 500; i++) {
      this.userList.push({
        name: '胡金淼',
        sex: '男',
        ticketCard: '20188756',
        graduation: '镇海应行久第二外国语中学',
        examinationPoint: '镇海蛟川书院',
        examinationDate: '2018年09月12日',
        waitintTime: '08:00-08:25',
        bianhao: '09070',
        zwh: 23,
        pc: '第一批',
        examinationTime: '08:30-08:55',
        img: 'http://i1.umei.cc/uploads/tu/201712/9999/a1837a175d.jpg'
      })
    }
  },
  mounted () {
    this.downloadPdf()
  },
  methods: {
    downloadPdf () {
      let that = this
      let htmlEml = document.querySelector(`#downloadPaper`)
      that.$http.covert2Pdf({ data: htmlEml.innerHTML }).then(res => {
        if (res.code === 20000) {
          window.open(res.data.data)
          // _item.downloading = false
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
p{
  margin: 0;
}
.download-paper{
  width: 700px;
  margin: 0 auto;
}
.dp-box{
  width: 328px;
  height: 230px;
  border: 1px solid #000;
  color: #000;
  font-size: 11px;
  float: left;
  margin: 15px 9px;
  .dp-top{
    height: 152px;
    border-bottom: 1px solid #000;
    position: relative;
    padding-right: 103px;
    overflow: hidden;
    .top-left{
      border-right: 1px solid #000;
      padding: 6px 10px;
      height: 100%;
      box-sizing: border-box;
    }
    .top-right{
      position: absolute;
      right: 7px;
      top: 14px;
      .img{
        width: 89px;
        height: 127px;
        background-position: center;
        background-size: cover;
        background-repeat: no-repeat;
      }
    }
    .title{
      font-size: 12px;
      text-align: center;
      line-height: 20px;
    }
    .title-card{
      font-size: 15px;
      line-height: 20px;
      text-align: center;
      font-weight: 600;
      margin: 11px auto 13px;
    }
    .tl-block{
      float: left;
      width: 60%;
    }
    .tl-info{
      width: 40%;
    }
    .graduation-school{
      position: relative;
      padding-left: 56px;
      .lab{
        position: absolute;
        left: 0;
        top: 0;
      }
    }
  }
  .dp-bottom{
    padding: 10px;
    .dpb-block{
      width: 50%;
      float: left;
    }
  }
}
</style>
